/*
DO FILE FOR REPLICATION FOR 
Local labor market effects of nuclear power plants

BY Duha T. Altindag, Reem El Cheikh Taha, Jennifer U. Jones, and R. Alan Seals, Jr., May 2025
*/

**"${path}clean_data/Final Panel.dta" includes all counties in the USA
**"${path}clean_data/Considered panel.dta" includes only the counties that constructed their first reactor between 1974 and 1978 which is our sample

clear all
set more off

global path "C:/Users/Reem/Desktop/stata files/"

********************TABLES

*****Table 1 & Appendix Figures A1 and A2

*****Considered vs Not Considered
use "${path}clean_data/proxies.dta", clear

label var lg_quake_dist "Log of distance of nearest earthquake"
label var lg_city_dist "Log of distance of nearest populated city"
label var av_prec1901_2000 "Average Precipitation 1901-2000"
label var av_temp1901_2000 "Average Temperature 1901-2000"
label var ElevFt "Highest Point"
label var pop_persq60 "Population per square mile"
label var water_land_ratio "Water to land area ratio"

***Panel A Column 1
logit county_considered lg_quake_dist lg_city_dist av_prec1901_2000 av_temp1901_2000 ElevFt  pop_persq60 water_land_ratio  c.lg_quake_dist#c.lg_city_dist c.water_land_ratio#c.av_prec1901_2000 c.ElevFt#c.lg_quake_dist c.av_prec1901_2000#c.av_temp1901_2000 c.lg_city_dist#c.av_temp1901_2000 c.av_temp1901_2000#c.av_temp1901_2000 c.lg_quake_dist#c.av_prec1901_2000
margins, dydx(*) post
estimates store margins1

esttab margins1 using "${path}results/table1_panel A.csv", ///
  se b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) ///
    label  mtitles("Considered vs Never Considered") replace
di  e(r2_p)

***for robustness, not used
//probit county_considered lg_quake_dist lg_city_dist av_prec1901_2000 av_temp1901_2000 ElevFt  pop_persq60 water_land_ratio  c.lg_quake_dist#c.lg_city_dist c.water_land_ratio#c.av_prec1901_2000 c.ElevFt#c.lg_quake_dist c.av_prec1901_2000#c.av_temp1901_2000 c.lg_city_dist#c.av_temp1901_2000 c.av_temp1901_2000#c.av_temp1901_2000 c.lg_quake_dist#c.av_prec1901_2000
//margins, dydx(_all)

***Appendix Figure A1
///graphs
logit county_considered lg_quake_dist lg_city_dist av_prec1901_2000 av_temp1901_2000 ElevFt  pop_persq60 water_land_ratio  c.lg_quake_dist#c.lg_city_dist c.water_land_ratio#c.av_prec1901_2000 c.ElevFt#c.lg_quake_dist c.av_prec1901_2000#c.av_temp1901_2000 c.lg_city_dist#c.av_temp1901_2000 c.av_temp1901_2000#c.av_temp1901_2000 c.lg_quake_dist#c.av_prec1901_2000
margins, dydx(_all) 
predict ps

twoway (kdensity ps if county_considered==1) ///
(kdensity ps if county_considered==0, lpattern(dash)), ///
ytitle(Density) xtitle(Propensity Score) legend(label(1 "Considered") label(2 "Never Considered"))
graph export "${path}results/FigureA1.png", replace

***Panel B Column 1
///HS is 5908 which is not right in GEOFIPS 16019
replace HS=. if GEOFIPS==16019
label var black "Percentage of Blacks (1950-1960)"
label var years65over "Percentage of 65 years and older population (1950-1960)"
label var HS "Percentage of population 25+ with HS degree or higher (1960)"
label var foreign "Percentage of Foreign Born (1960)"
label var farms "Percent of farms in land area (1950-1960)"
label var med_houseval "Log of Median of House Value (1950-1960)"
label var med_rent "Log of Median of House Rent (1950-1960)"
label var owner_occ "Percentage of Owner-Occupied Houses (1950-1960)"
label var emp_rate "Employment Rate (1950-1960)"
label var med_fam_income "Log of Median Family Income (1950-1960)"
eststo clear
foreach x in black years65over HS foreign farms med_houseval med_rent owner_occ emp_rate med_fam_income{
psmatch2 county_considered, outcome(`x') pscore(ps) neighbor(1) common  caliper(0.01)
    eststo `x'
 }
esttab using "${path}results/table1_panel B.csv", ///
    b(%9.3f) se(%9.3f) ///
    star(* 0.1 ** 0.05 *** 0.01) ///
    nogaps noconstant label replace 
	
 ***Appendix Figure A2
pstest  water_land_ratio av_prec1901_2000 av_temp1901_2000 pop_persq60 ElevFt lg_quake_dist lg_city_dist, label graph both 
graph export "${path}results/FigureA2.png", replace
* Rename variables back after if needed

***treated vs control
use "${path}clean_data/proxies.dta", clear

label var lg_quake_dist "Log of distance of nearest earthquake"
label var lg_city_dist "Log of distance of nearest populated city"
label var av_prec1901_2000 "Average Precipitation 1901-2000"
label var av_temp1901_2000 "Average Temperature 1901-2000"
label var ElevFt "Highest Point"
label var pop_persq60 "Population per square mile"
label var water_land_ratio "Water to land area ratio"

***Panel A Column 2
logit treated lg_quake_dist lg_city_dist av_prec1901_2000 av_temp1901_2000 ElevFt  pop_persq60 water_land_ratio  c.lg_quake_dist#c.lg_city_dist c.water_land_ratio#c.av_prec1901_2000 c.ElevFt#c.lg_quake_dist c.av_prec1901_2000#c.av_temp1901_2000 c.lg_city_dist#c.av_temp1901_2000 c.av_temp1901_2000#c.av_temp1901_2000 c.lg_quake_dist#c.av_prec1901_2000
margins, dydx(*) post
estimates store margins2
esttab margins2 using "${path}results/table1_panel A.csv", ///
  se b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) ///
    label  mtitles("Treated vs Control") append
di  e(r2_p)
*note that in table1_panel A.csv column 2 is under column 1 in the same sheet

logit treated lg_quake_dist lg_city_dist av_prec1901_2000 av_temp1901_2000 ElevFt  pop_persq60 water_land_ratio  c.lg_quake_dist#c.lg_city_dist c.water_land_ratio#c.av_prec1901_2000 c.ElevFt#c.lg_quake_dist c.av_prec1901_2000#c.av_temp1901_2000 c.lg_city_dist#c.av_temp1901_2000 c.av_temp1901_2000#c.av_temp1901_2000 c.lg_quake_dist#c.av_prec1901_2000
margins, dydx(_all) 
predict ps


***for robustness, not used
//probit treated lg_quake_dist lg_city_dist av_prec1901_2000 av_temp1901_2000 ElevFt  pop_persq60 water_land_ratio  c.lg_quake_dist#c.lg_city_dist c.water_land_ratio#c.av_prec1901_2000 c.ElevFt#c.lg_quake_dist c.av_prec1901_2000#c.av_temp1901_2000 c.lg_city_dist#c.av_temp1901_2000 c.av_temp1901_2000#c.av_temp1901_2000 c.lg_quake_dist#c.av_prec1901_2000
//margins, dydx(_all)
 
***Panel B Column 2
replace HS=. if GEOFIPS==16019
label var black "Percentage of Blacks (1950-1960)"
label var years65over "Percentage of 65 years and older population (1950-1960)"
label var HS "Percentage of population 25+ with HS degree or higher (1960)"
label var foreign "Percentage of Foreign Born (1960)"
label var farms "Percent of farms in land area (1950-1960)"
label var med_houseval "Log of Median of House Value (1950-1960)"
label var med_rent "Log of Median of House Rent (1950-1960)"
label var owner_occ "Percentage of Owner-Occupied Houses (1950-1960)"
label var emp_rate "Employment Rate (1950-1960)"
label var med_fam_income "Log of Median Family Income (1950-1960)"
eststo clear
foreach x in black years65over HS foreign farms med_houseval med_rent owner_occ emp_rate med_fam_income{
psmatch2 treated, outcome(`x') pscore(ps) neighbor(1) common  caliper(0.01)
    eststo `x'
 }
esttab using "${path}results/table1_panel B.csv", ///
    b(%9.3f) se(%9.3f) ///
    star(* 0.1 ** 0.05 *** 0.01) ///
    nogaps noconstant label append 
*note that in table1_panel B.csv column 2 is under column 1 in the same sheet

*******Table 3: Summary Statistics Table
use "${path}clean_data/Final Panel.dta", clear
gen restUS=0 
replace restUS=1 if treated==0 //include control group
replace restUS=1 if treated==. //include all other counties that did not consider constructing a plant
drop if first_construction_start<1974 // we only included counties that started construction in 1974 to calculate synthetic control so we can have enough pretreatment period (at least 5 years)

***drop counties whose status is future i.e didnt start construction yet
drop if GEOFIPS==6019
drop if GEOFIPS==16019
drop if GEOFIPS==16075
drop if GEOFIPS==47105
drop if GEOFIPS==49015
**drop counties that couldn't produce a synthetic control
drop if GEOFIPS==22125
drop if GEOFIPS==28021
***drop counties that built their first plant after 1978
drop if GEOFIPS==12075

*label
label variable emp_rate "Emp. to Pop. Ratio"
label variable wages_Rpercapita "Per Capita Wages & Salaries"
label variable personal_income_Rpercapita "Total Personal Inc."

//table 3
local y "emp_rate wages_Rpercapita personal_income_Rpercapita"
eststo treated: estpost sum `y' if year<=1973 & treated==1
eststo control: estpost sum `y' if year<=1973 & treated==0
eststo rest: estpost sum `y' if year<=1973 & restUS==1
esttab treated control rest using "${path}results/table3.csv", ///
    cells("mean(fmt(3))") ///
    mtitles("Treated" "Control" "Rest of the US") label replace

eststo clear
*note that the stars are coming from the ttest below

*differences treated vs control: stars in column 2
local y "emp_rate wages_Rpercapita personal_income_Rpercapita"
eststo treated: estpost sum `y' if year<=1973 & treated==1
eststo control: estpost sum `y' if year<=1973 & treated==0	
eststo diff: estpost ttest `y' if year<=1973, by(treated) unequal
esttab diff

*differences treated vs rest of the US: stars in column 3
local y "emp_rate wages_Rpercapita personal_income_Rpercapita "
eststo treated: estpost sum `y' if year<=1973 & restUS==0 
eststo rest: estpost sum `y' if year<=1973 & restUS==1
eststo diff: estpost ttest `y' if year<=1973, by(restUS) unequal
esttab diff


*******Table 4: main Regression using regular DD (treated and control only)
use "${path}clean_data/Considered Panel.dta", clear
label variable construction_dummy "Construction"
label variable commercial_dummy "Commercial Operation"
label variable emp_rate "Emp.to Pop. Ratio"
label variable log_wages_Rpercapita "Log of  Per Capita Wages & Salaries"
label variable wages_Rpercapita "Per Capita Wages & Salaries"
eststo clear
eststo: areg emp_rate construction_dummy commercial_dummy i.year, a(GEOFIPS) cluster(GEOFIPS)
eststo: areg log_wages_Rpercapita construction_dummy commercial_dummy i.year, a(GEOFIPS) cluster(GEOFIPS)
eststo: areg wages_Rpercapita construction_dummy commercial_dummy i.year, a(GEOFIPS) cluster(GEOFIPS)
esttab using "${path}results/table4.csv", ///
    b(%9.3f) se(%9.3f) ///
    star(* 0.1 ** 0.05 *** 0.01)  stat(N, fmt(%9.0f) label("N")) ///
    nogaps label keep(construction_dummy commercial_dummy) replace 
    
eststo clear


*******Table 5: Income components
use "${path}clean_data/Considered Panel.dta", clear
label variable construction_dummy "Construction"
label variable commercial_dummy "Commercial Operation"
label variable emp_rate "Emp.to Pop. Ratio"
label variable log_wages_Rpercapita "Log of  Per Capita Wages & Salaries"
label variable wages_Rpercapita "Per Capita Wages & Salaries"
label variable supplements_Rpercapita "Suppl. to Wages & Salaries"
label variable proprietors_income_Rpercapita "Propri. Inc."
label variable dividends_Rpercapita "Div. Int.& Rental Inc."
label variable transfer_Rpercapita "Transfers"
label variable contribution_Rpercapita "Contr. to Gov. Soc. Ins."
label variable personal_income_Rpercapita "Total Personal Inc."
eststo clear
eststo: areg wages_Rpercapita construction_dummy commercial_dummy    i.year , a(GEOFIPS) cluster(GEOFIPS)
eststo: areg supplements_Rpercapita construction_dummy commercial_dummy    i.year, a(GEOFIPS) cluster(GEOFIPS)
eststo: areg proprietors_income_Rpercapita construction_dummy commercial_dummy    i.year,  a(GEOFIPS) cluster(GEOFIPS)
eststo: areg dividends_Rpercapita construction_dummy commercial_dummy    i.year ,  a(GEOFIPS) cluster(GEOFIPS)
eststo: areg transfer_Rpercapita construction_dummy commercial_dummy i.year,  a(GEOFIPS) cluster(GEOFIPS)
eststo: areg contribution_Rpercapita construction_dummy commercial_dummy i.year,  a(GEOFIPS) cluster(GEOFIPS)
eststo: areg personal_income_Rpercapita construction_dummy  commercial_dummy   i.year , a(GEOFIPS) cluster(GEOFIPS)
esttab using "${path}results/table5.csv", ///
    b(%9.2f) se(%9.2f) ///
    star(* 0.1 ** 0.05 *** 0.01) ///
    nogaps label keep(construction_dummy commercial_dummy) ///
	replace ///
    
eststo clear

*******Table 6: Emp by Industry
use "${path}clean_data/Considered Panel.dta", clear
label variable construction_dummy "Construction"
label variable commercial_dummy "Commercial Operation"
label variable agri_emprate "Agr. Forest. & Fishing"
label variable agri_earning_Rpercapita "Agr. Forest. & Fishing"
label variable manuf_emprate "Manuf."
label variable manuf_earning_Rpercapita "Manuf."
label variable mining_emprate "Mining"
label variable mining_earning_Rpercapita "Mining"
label variable const_emprate "Constr."
label variable const_earning_Rpercapita "Constr."
label variable trans_emprate "Transp. & Pub. Util."
label variable trans_earning_Rpercapita "Transp. & Pub. Util."
label variable wholesale_emprate "Whole. Trade"
label variable wholesale_earning_Rpercapita "Whole. Trade"
label variable retail_emprate "Ret. Trade"
label variable retail_earning_Rpercapita "Ret. Trade"
label variable finance_emprate "Fin. Ins. & Real Est."
label variable finance_earning_Rpercapita "Fin. Ins. & Real Est."
label variable services_emprate "Services"
label variable services_earning_Rpercapita "Services"
label variable gov_emprate "Gov. & Gov. Enter."
label variable gov_earning_Rpercapita "Gov. & Gov. Enter."
eststo clear
foreach i in  agri_emprate manuf_emprate mining_emprate const_emprate trans_emprate wholesale_emprate retail_emprate finance_emprate services_emprate gov_emprate{
eststo: areg `i'  construction_dummy  commercial_dummy  i.year,a(GEOFIPS) cluster(GEOFIPS)
}
esttab using "${path}results/table6.csv", b(%9.3f) se(%9.3f) star(* 0.1 ** 0.05 *** 0.01) label nogaps replace ///
keep(construction_dummy commercial_dummy)

*******Table 7: Wages by Industry
use "${path}clean_data/Considered Panel.dta", clear
label variable construction_dummy "Construction"
label variable commercial_dummy "Commercial Operation"
label variable agri_emprate "Agr. Forest. & Fishing"
label variable agri_earning_Rpercapita "Agr. Forest. & Fishing"
label variable manuf_emprate "Manuf."
label variable manuf_earning_Rpercapita "Manuf."
label variable mining_emprate "Mining"
label variable mining_earning_Rpercapita "Mining"
label variable const_emprate "Constr."
label variable const_earning_Rpercapita "Constr."
label variable trans_emprate "Transp. & Pub. Util."
label variable trans_earning_Rpercapita "Transp. & Pub. Util."
label variable wholesale_emprate "Whole. Trade"
label variable wholesale_earning_Rpercapita "Whole. Trade"
label variable retail_emprate "Ret. Trade"
label variable retail_earning_Rpercapita "Ret. Trade"
label variable finance_emprate "Fin. Ins. & Real Est."
label variable finance_earning_Rpercapita "Fin. Ins. & Real Est."
label variable services_emprate "Services"
label variable services_earning_Rpercapita "Services"
label variable gov_emprate "Gov. & Gov. Enter."
label variable gov_earning_Rpercapita "Gov. & Gov. Enter."
eststo clear
foreach i in agri_earning_Rpercapita manuf_earning_Rpercapita mining_earning_Rpercapita const_earning_Rpercapita trans_earning_Rpercapita wholesale_earning_Rpercapita retail_earning_Rpercapita finance_earning_Rpercapita services_earning_Rpercapita gov_earning_Rpercapita{
eststo: areg `i'  construction_dummy  commercial_dummy  i.year,a(GEOFIPS) cluster(GEOFIPS)
}
esttab using "${path}results/table7.csv", b(%9.3f) se(%9.3f) star(* 0.1 ** 0.05 *** 0.01) nogaps label replace ///
keep(construction_dummy commercial_dummy)


*****Table 8: Spillover Impact
use "${path}clean_data/panel of neighbors of both treated and control according to population.dta", clear
label variable construction_dummy "Construction"
label variable commercial_dummy "Commercial Operation"
label variable emp_rate "Emp.to Pop. Ratio"
label variable log_wages_Rpercapita "Log of  Per Capita Wages & Salaries"
label variable wages_Rpercapita "Per Capita Wages & Salaries"
eststo clear
eststo: areg emp_rate construction_dummy commercial_dummy i.year, a(GEOFIPS) cluster(GEOFIPS)
eststo: areg log_wages_Rpercapita construction_dummy commercial_dummy    i.year , a(GEOFIPS) cluster(GEOFIPS)
eststo: areg wages_Rpercapita construction_dummy commercial_dummy    i.year , a(GEOFIPS) cluster(GEOFIPS)
esttab using "${path}results/table8.csv", b(%9.3f) se(%9.3f) star(* 0.1 ** 0.05 *** 0.01) nogaps label replace ///
keep(construction_dummy commercial_dummy)


******Table 9: Gov Finance
use "${path}clean_data/Considered Panel_gov finances.dta", clear
//1 county, 2 municipal, 3 township, 4 special district, 5 school district
g cog_years=1 if year==1967 | year==1972 | year==1977 | year==1982 | year==1987 | year==1992 | year==1997 | year==2002 | year==2007 | year==2012 | year==2017 | year==2022
label variable construction_dummy "Construction"
label variable commercial_dummy "Commercial Operation"
label variable log_revenue "Total Revenues"
label variable log_revenue_pc "Per capita Revenues"
label variable log_expenditure "Total Expenditure"
label variable log_expenditure_pc "Per Capita Expenditure"
label variable log_educ_pc "Education"
label variable log_gov_pc "Gov. Admin."
label variable log_safety_pc "Public Safety"
label variable log_assistance_pc "Public Assistance"
label variable log_works_pc "Public Works"
label variable log_other_exp_pc "Other"

eststo clear
eststo: reghdfe log_revenue construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_revenue construction_dummy commercial_dummy if type_code<=3,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_revenue construction_dummy commercial_dummy if type_code==4 | type_code==5,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_revenue_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
esttab using "${path}results/table9.csv", b(%9.3f) se(%9.3f) star(* 0.1 ** 0.05 *** 0.01) keep(construction_dummy commercial_dummy) label nogaps replace

eststo clear
eststo: reghdfe log_expenditure construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_expenditure construction_dummy commercial_dummy if type_code<=3,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_expenditure construction_dummy commercial_dummy if type_code==4 | type_code==5,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_expenditure_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
esttab using "${path}results/table9.csv", b(%9.3f) se(%9.3f) star(* 0.1 ** 0.05 *** 0.01) keep(construction_dummy commercial_dummy) label nogaps append

eststo clear
eststo: reghdfe log_educ_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_gov_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_safety_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_assistance_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_works_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
eststo: reghdfe log_other_exp_pc construction_dummy commercial_dummy,absorb(govsid year) cluster(GEOFIPS)
esttab using "${path}results/table9.csv", b(%9.3f) se(%9.3f) star(* 0.1 ** 0.05 *** 0.01) keep(construction_dummy commercial_dummy) label nogaps append





